require('./page.css');
let cp = require('cp');

let org_list;
cp.ajaxUrl({
  controller: 'account',
  cmd: 'com.rel.porg.pb.login_select_req',
  async: false,
  success: function(res) {
    // body...
    org_list = res.org_list;
  },
});
avalon.define({
  $id: 'mc_choose_organization',
  organization_list: org_list,
  bindChooseOrg: function(orgId) {
    // body...
    cp.ajaxUrl({
      controller: 'account',
      cmd: 'com.rel.porg.pb.login_confirm_req',
      data: {'org_id': orgId},
      success: function(res) {
        // body...
        cp.setCookie('token', res.token, 12);
        const libs = require('libs');
        libs.sendParamBetweenPages('common', 'orgid', res.orgid);
        window.location.href = cp.PAGE_ROOT + 'index/index/page.html';
      },
    });
  },
});
